#include <string>

using namespace std;

string replace(const string & str, const string & substr, const string & repstr, bool all)
{
	string rstr(substr);
	string::size_type pos = 0;
	if(all == true) {
		while(1) {
			pos = rstr.find(substr, pos);
			if(pos == string::npos) {
				return rstr;
				break;
			}else{
				rstr = rstr.replace(pos, substr.length(), repstr);
				pos = pos + repstr.length();
			}
		}
	}
}

int main()
{
	string s = "abbbccddee";
	cout << replace(s, "bb", , bb)
}